package top.kaoshanji.p1ch03a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;

/**
 * 代码清单 p1ch03a-06：字节缓冲区的视图
 * author kaoshanji
 * ^_^
 * create time 2025/1/5 20:08
 */
public class ByteBufferExample04 {

    private static final Logger logger = LogManager.getLogger(ByteBufferExample04.class);

    public static void main(String[] args) {
        logger.info("...代码清单 p1ch03a-06：字节缓冲区的视图...");

        ByteBuffer buffer = ByteBuffer.allocate(32);
        buffer.putInt(1); // 读取位置为 4
        IntBuffer intBuffer = buffer.asIntBuffer();
        intBuffer.put(2);

        System.out.println(buffer.getInt());

    }

}
